/***********************************************************************************
** @file	WMIConnectionMngTest.h
** @author	Carlos Armando Orellana Pacolla
** @author  Nestor Felipe
** @date	Jul 28, 2010
**
** @desc	This class test the WMI_ConnectionManager methods
************************************************************************************/

#include "../Unit--/unit--.h"
#include <cstdio>
#include "../../wmi_constants.h"
#include "../../wmi_connectionmanager.h"

using namespace unit_minus;

testSuite(WMIReaderSuite);

/**
* Test the createConnection method for local connection
*/
testCase(createConnectionTest_local, WMIReaderSuite)
{
    cout << "------- Start WMI_ConnectionManager::createConnectionTest_local Test -------" << endl;
	WMI_ConnectionManager* wmiMng = new WMI_ConnectionManager();
	wmiMng->initCOMSecurityConfiguration();
	WMI_Connection wmiConnection;

	WMI_HResult *expected = new WMI_HResult(L"", W_OK, 0);
	WMI_HResult *result = wmiMng->createConnection(PC_LOCAL_USER, PC_LOCAL_PASSWORD, PC_NAMESPACE, wmiConnection);

	assertTrue(equalValueInfo(expected->getHRESULT(), result->getHRESULT()));

	result = wmiMng->createConnection(PC_LOCAL_USER, PC_LOCAL_PASSWORD, PC_NAMESPACE, wmiConnection);

	assertTrue(result->getHRESULT() == 0);

	wmiConnection.close();

	delete wmiMng;
    delete result;
    delete expected;
    cout << "------- End WMI_ConnectionManager::createConnectionTest_local Test -------" << endl;
    cout << endl;
    system("PAUSE");
}

/**
* Test the createConnection method for local connection
*/
testCase(createConnectionTest_remote, WMIReaderSuite)
{
    cout << "-------- Start WMI_ConnectionManager::createConnectionTest_remote --------" << endl;
	WMI_ConnectionManager* wmiMng = new WMI_ConnectionManager();
	wmiMng->initCOMSecurityConfiguration();
	WMI_Connection wmiConnection;

	WMI_HResult *expected = new WMI_HResult(L"", W_OK, 0);
	WMI_HResult *result = wmiMng->createConnection(PC_USER, PC_PASSWORD, PC_IP_REMOTE_HOST, PC_NAMESPACE, wmiConnection);

	assertTrue(equalValueInfo(expected->getHRESULT(), result->getHRESULT()));
	
	wmiConnection.close();
	delete wmiMng;
    delete result;
    delete expected;
    cout << "-------- End WMI_ConnectionManager::createConnectionTest_remote Test --------" << endl;
    cout << endl;
    system("PAUSE");
}